package android.itv.view;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.itv.R;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.MediaController;
import android.widget.ProgressBar;
import android.widget.VideoView;

public class ViewTivi extends Activity
{
    VideoView videoview;
    ProgressBar progressBar;
    ProgressDialog dialog;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.viewtivi);
        
        String url=getIntent().getStringExtra("URL");
        String s=getResources().getString(R.string.txtloading);
        dialog=ProgressDialog.show(this, "",s,false);
        videoview=(VideoView)findViewById(R.id.videoView1);
        
        videoview.setMediaController(new MediaController(this));
        videoview.setVideoURI(Uri.parse(url));
        
      /*  videoview.setOnPreparedListener(new OnPreparedListener()
	{
	    
	    @Override
	    public void onPrepared(MediaPlayer mp)
	    {
		dialog.dismiss();
	    } 
	   
	});
        videoview.setOnErrorListener(new OnErrorListener()
	{
	    
	    @Override
	    public boolean onError(MediaPlayer mp, int what, int extra)
	    {
		dialog.dismiss();
		Intent intent=new Intent(getApplicationContext(),Watch.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		Log.d("error","error");
		startActivity(intent);
		return true;
	    }
	});*/
        videoview.start();        
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
	Log.d("Keycode",keyCode+"");
	if(keyCode==KeyEvent.KEYCODE_BACK)
	{
	    dialog.dismiss();
	}
        return super.onKeyDown(keyCode, event);
    }
    
}
